<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            /* 买卖股票的最佳时机Ⅱ的不同在于，它每一天都可以买入，每一天都可以卖出。因此只需要判断当前卖有利润即可 */
            var maxProfit = function (prices) {
                let profit = 0
                for (let i = 1; i < prices.length; i++) {
                    if (prices[i] > prices[i - 1]) {
                        profit += prices[i] - prices[i - 1]
                    }
                }
                return profit
            }
        </script>
    </body>
</html>
